package com.store.controller;

import com.store.domain.R;
import com.store.domain.entity.Category;
import com.store.service.CategoryService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author yu
 * @date 2024/6/26
 */
@RestController
@RequestMapping("category")
public class CategoryController {
    @Resource
    private CategoryService categoryService;
    @GetMapping("getCategoryPage")
    public R getCategoryPage(Integer pageNum, Integer pageSize, String name) {
        return categoryService.getCategoryPage(pageNum, pageSize, name);
    }
    @GetMapping("getAllCategory")
    public R getAllCategory() {
        return categoryService.getAllCategory();
    }
    @PostMapping("addCategory")
    public R addCategory(@RequestBody Category category) {
        return categoryService.addCategory(category);
    }
    @DeleteMapping("deleteCategory/{ids}")
    public R deleteCategory(@PathVariable Integer[] ids) {
        return categoryService.deleteCategory(ids);
    }
    @GetMapping("getCategoryById/{id}")
    public R getCategoryById(@PathVariable Integer id) {
        return categoryService.getCategoryById(id);
    }
    @PutMapping("updateCategory")
    public R updateCategory(@RequestBody Category category) {
        return categoryService.updateCategory(category);
    }


}
